package com.leesche.zcsp.node.web.vo;

import com.leesche.zcsp.node.utils.web.mathematical.MoneyCount;
import com.leesche.zcsp.node.web.constants.Constants;
import com.leesche.zcsp.node.web.model.PubDevicePayDetail;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author Jerry Chan
 * @version V1.0
 * @Title: node
 * @Package com.leesche.zcsp.node.web.vo
 * @Description:( 收益流水 )
 * @date 2016年11月04日 17:55
 */
public class IncomeDetail implements Serializable {

    private String placeName;
    private Long deviceid;
    private String deviceName;
    private String queryDate;
    private Integer moreIndex;
    private List<IncomeItem> incomeItems;

    public IncomeDetail(Long deviceid, String queryDate, Integer moreIndex, List<IncomeItem> incomeItems) {
        this.deviceid = deviceid;
        this.queryDate = queryDate;
        this.moreIndex = moreIndex;
        this.incomeItems = incomeItems;
    }

    public IncomeDetail(String placeName, Long deviceid, String deviceName, String queryDate, Integer moreIndex, List<IncomeItem> incomeItems) {
        this.placeName = placeName;
        this.deviceid = deviceid;
        this.deviceName = deviceName;
        this.queryDate = queryDate;
        this.moreIndex = moreIndex;
        this.incomeItems = incomeItems;
    }

    public String getPlaceName() {
        return placeName;
    }

    public void setPlaceName(String placeName) {
        this.placeName = placeName;
    }

    public Long getDeviceid() {
        return deviceid;
    }

    public void setDeviceid(Long deviceid) {
        this.deviceid = deviceid;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public List<IncomeItem> getIncomeItems() {
        return incomeItems;
    }

    public void setIncomeItems(List<IncomeItem> incomeItems) {
        this.incomeItems = incomeItems;
    }

    public String getQueryDate() {
        return queryDate;
    }

    public void setQueryDate(String queryDate) {
        this.queryDate = queryDate;
    }


    public Integer getMoreIndex() {
        return moreIndex;
    }

    public void setMoreIndex(Integer moreIndex) {
        this.moreIndex = moreIndex;
    }

    public class IncomeItem {
        private Long incomeItemid;
        private String incomeText;
        private String incomeTime;

        public IncomeItem(Long incomeItemid, String incomeText, String incomeTime) {
            this.incomeItemid = incomeItemid;
            this.incomeText = incomeText;
            this.incomeTime = incomeTime;
        }

        public void mathematicalTotal(PubDevicePayDetail pubDevicePayDetail) {
            Integer choose = pubDevicePayDetail.getPaytype();

            if (choose > 3 && choose < 10) {
                choose = 4;
            } else if (choose >= 10) {
                choose = 5;
            }

            switch (choose) {
                case 1: //硬币收入
                    //<span>一元硬币</span><i>number</i>个<em>￥total</em>
                    this.incomeText = this.incomeText.replace("number", String.valueOf(pubDevicePayDetail.getCoin()));
                    this.incomeText = this.incomeText.replace("total", String.valueOf(pubDevicePayDetail.getCoin() + ".00"));
                    break;
                case 2: //微信支付
                    //微信支付按百分比转换金额
                    //<p>微信支付</p><em>￥total</em>
                    Long wechaPayTotal = Long.parseLong(pubDevicePayDetail.getCoin().toString());
                    this.incomeText = this.incomeText.replace("total", Constants.DECIMAL_FORMAT.format(MoneyCount.percentageCount(wechaPayTotal, Constants.percentage)));
                    break;
                case 3: //支付宝支付
                    //支付宝支付按百分比转换金额
                    //<p>支付宝支付</p><em>￥total</em>
                    Long AliPayTotal = Long.parseLong(pubDevicePayDetail.getCoin().toString());
                    this.incomeText = this.incomeText.replace("total", Constants.DECIMAL_FORMAT.format(MoneyCount.percentageCount(AliPayTotal, Constants.percentage)));
                    break;
                case 4: //纸币收入
                    //<span>cach</span>元<i>number</i>张<em>￥total</em>
                    Integer cash = Constants.CashType.getCachType(pubDevicePayDetail.getPaytype());
                    Integer quantity = pubDevicePayDetail.getCoin();
                    this.incomeText = this.incomeText.replace("cach", String.valueOf(cash));
                    this.incomeText = this.incomeText.replace("number", String.valueOf(quantity));
                    this.incomeText = this.incomeText.replace("total", Constants.DECIMAL_FORMAT.format(MoneyCount.worthCount(cash, quantity).doubleValue()));
                    break;
                case 5:
                    this.incomeText = this.incomeText.replace("total", String.valueOf(pubDevicePayDetail.getCoin()));
                    break;
                default:
                    this.incomeText = "未知异常";
                    break;
            }

        }

        public Long getIncomeItemid() {
            return incomeItemid;
        }

        public void setIncomeItemid(Long incomeItemid) {
            this.incomeItemid = incomeItemid;
        }

        public String getIncomeText() {
            return incomeText;
        }

        public void setIncomeText(String incomeText) {
            this.incomeText = incomeText;
        }

        public String getIncomeTime() {
            return incomeTime;
        }

        public void setIncomeTime(String incomeTime) {
            this.incomeTime = incomeTime;
        }
    }


}
